<template>
  <div class="index">index</div>
  <image class="logo" src="/static/logo.png" mode="widthFix" />

  <button @click="login">测试登录</button>
  <button @click="getMobileCode">获取验证码</button>

  <view>计数:{{ store.count }}</view>
  <button @click="store.increment">减</button>
  <button @click="store.decrement">加</button>
</template>

<script lang="ts" setup>
import { getCodeAPI, postLoginPassworAPI } from '@/apis/common'
import { useCounterStore } from '@/stores/counter'
import { request, service, type LoginData } from '@/utils/request'
import { ref } from 'vue'

const store = useCounterStore()
const formData = ref({
  mobile: '13211112222',
  // 密码 abc123456 测试：出现非 10000 的情况
  password: 'abc12345',
})

const login = async () => {
  // const res = await service.request({
  //   url: '/login/password',
  //   method: 'POST',
  //   data: .value,
  // })
  // console.log(res)
  // 测试登录2
  // const res = await request<LoginData>('/login/password', 'POST', formData.value)
  // console.log(res)
  // 测试登录API
  const res = await postLoginPassworAPI(formData.value)
  console.log(res)
}

// 获取验证码
const getMobileCode = async () => {
  const res = await getCodeAPI({ mobile: formData.value.mobile, type: 'login' })
  console.log(res)
}
</script>

<style lang="scss" scoped></style>
